home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / SAT / SATcollision][ ƒ / SATcollision][.p < prev    next >
Encoding:
Text File  |  1993-09-19  |  1.3 KB  |  50 lines  |  [TEXT/PJMM]

  1. {******************************}
  2. {********* SAT Collision ][ **********}
  3. {******************************}
  4.  
  5. {A more advanced version of SAT Collision, demonstrating the use of callback routines}
  6. {(hit task) for collision handling. What has happened is that the apples switch between}
  7. {good and bad, and we are not supposed to eat it when it's bad.}
  8.  
  9. program SATcollisionII;
  10.  
  11.     uses
  12.         SAT, sMrEgghead, sApple;
  13.  
  14.     var
  15.         gameWind: WindowPtr;
  16.         ignoreSp: SpritePtr;
  17.         l: longint;
  18.         p: Point;
  19. begin
  20. {Standard Inits are done by Think Pascal.}
  21.  
  22.     ConfigureSAT(true, VPositionSort, BackwardCollision, 32);
  23.     gameWind := InitSAT(128, 129, 512, 322);
  24.  
  25.     initMrEgghead;
  26.     initApple;
  27.  
  28.     ShowWindow(gameWind);
  29.     SelectWindow(gameWind);
  30.     PeekOffscreen;
  31.  
  32.     GetMouse(p);
  33.     ignoreSp := NewSprite(0, p.h, p.v, @HandleMrEgghead, @SetupMrEgghead, @HitMrEgghead);
  34.     ignoreSp := NewSprite(0, 0, Rand(offSizeV - 32), @HandleApple, @SetupApple, @HitApple);
  35.  
  36. {SATSoundOff;}
  37.     HideCursor;
  38.  
  39.     repeat
  40.         l := TickCount;
  41.         RunSAT(true);
  42. {Start a new sprite once in a while.}
  43.         if Rand(40) = 1 then
  44.             ignoreSp := NewSprite(0, 0, Rand(offSizeV - 32), @HandleApple, @SetupApple, @HitApple);
  45.         while l > TickCount - 2 do {Maximize speed to 30 fps}
  46.             ;
  47.     until Button;
  48.     ShowCursor;
  49.     SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
  50. end.